package com.lx.oms.controller.manager.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.utils.Utils;
import com.lx.oms.controller.dao.WOrderMapper;
import com.lx.oms.controller.entity.WOrderEntity;
import com.lx.oms.controller.manager.WOrderManager;

/**
 * 微信下单
 *
 * @author houzhong
 * @date 2018年8月08日 上午10:44:01
 */
@Component("wOrderManager")
public class WOrderManagerImpl implements WOrderManager {

	@Autowired
	private WOrderMapper wOrderMapper;
	
	@Override
	public List<WOrderEntity> listWOrder(Page<WOrderEntity> page, Query search) {
		return wOrderMapper.listForPage(page, search);
	}

	@Override
	public int saveWOrder(WOrderEntity wOrder) {
		if (wOrder.getId() == null) {
			wOrder.setId(Utils.id().toString());
		}
		return wOrderMapper.save(wOrder);
	}

	@Override
	public WOrderEntity getWOrderById(BigInteger id) {
		WOrderEntity wOrder = wOrderMapper.getObjectById(id);
		return wOrder;
	}

	@Override
	public int updateWOrder(WOrderEntity wOrder) {
		return wOrderMapper.update(wOrder);
	}

	@Override
	public int batchRemove(String[] id) {
		int count = wOrderMapper.batchRemove(id);
		return count;
	}
	
}
